package ewa

import (
	"fmt"
	"github.com/labstack/echo"
)

/* ewa Golbal Variables. 
	StaticRes ECHO_Static
*/
func HttpRoute_Mapping_StaticResource(e *echo.Echo) {

  // 遍历Resource 配置信息 链表
  for Res := StaticRes.ResList.Front(); Res != nil; Res = Res.Next() {
    // -----------------------------------
    // 使用Golang断言, 
    // 接口: Res.Value 
    // 强制转换为 --> 
    // 结构体类型: Resource
    R, ok := Res.Value.(Resource)
    // -----------------------------------

    if ok {
       //fmt.Println(R.HttpRoute)
       //fmt.Println(R.RealLocation)
       e.Static( R.HttpRoute, R.RealLocation )
        l:=fmt.Sprintf("----Echo/> Http-route '%s' mapping to localhost's Real-location '%s'",  
                          R.HttpRoute, R.RealLocation )
        Log(l)
    } else {
       //fmt.Println("can not convert")
        l:=fmt.Sprintf("----Echo/> Can not covert Resource type interface to struct" )
        Log(l)
    }
  }
}